﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    Periodical journal = ViewBag.Journal;
    ViewBag.Title = "稿件中心 - " + journal.Name;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<div id="content-header">
    <h1>
        稿件中心</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/console/index" class="tip-bottom"><i class="icon-home"></i>起始页</a> <a href="javascript:"
        class="current">稿件中心</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="alert alert-info">
                <button type="button" class="close" data-dismiss="alert">
                    &times;</button>
                <strong>注：</strong>如果您误删稿件，请联系管理员处理。
            </div>
            <div class="widget-box" style="margin-top: 0px;">
                <div class="widget-title">
                    <h5>
                        稿件中心</h5>
                </div>
                <div class="widget-content nopadding">
                    <table class="table table-bordered">
                        <thead>
                            <tr style="cursor: pointer;">
                                <th>
                                    标题
                                </th>
                                <th style="width: 13%">
                                    作者
                                </th>
                                <th style="width: 20%">
                                    稿件状态 
                                </th>
                                <th style="width: 20%">
                                    稿件范围
                                </th>
                                <th style="width: 10%">
                                    来稿时间
                                </th>
                                <th style="width: 17%">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                ItemListBox<Article> data = ViewBag.Article;
                                if (data.Data != null && data.Data.Any())
                                {
                                    foreach (var item in data.Data)
                                    {
                                <tr>
                                    <td>
                                        <a href="/workspace/console/articledetail/@item.Id">@item.Title</a>
                                    </td>
                                    <td style="text-align: center">
                                        @{string authors = string.Empty;
                                          item.ArticleAuthor.ForEach(
                                          c => { authors += c.AuthorName + "，"; });
                                          authors = authors.Trim();
                                          authors = authors.Remove(authors.Length - 1); }
                                        @authors
                                    </td>
                                    <td style="text-align: center">
                                        @if (item.Status == ArticleStatus.ZhuanShenWanCheng ||
                                            item.Status == ArticleStatus.ZhuanShenXiuDingWanCheng)
                                        {
                                            <span style="color: #51a351"><b>@item.Status.Mapping()</b></span>
                                        }
                                        else if(item.Status == ArticleStatus.ZhuanShen)
                                        {
                                            if(item.ExamineTotle == item.ExamineComplete){
                                                <span style="color: #51a351"><b>@item.Status.Mapping()</b><span> 专审进度 (@item.ExamineComplete/@item.ExamineTotle)</span></span> 
                                            }
                                            else{
                                                @item.Status.Mapping()<span> 专审进度 (@item.ExamineComplete/@item.ExamineTotle)</span>
                                            }
                                        }
                                        else
                                        {
                                            @item.Status.Mapping()
                                        }
                                        @if(item.Status == ArticleStatus.ZhuanShenDaiJiaoFei || item.Status == ArticleStatus.LuYong)
                                        {
                                            if(item.WaitPay!=0)
                                            {
                                                <span>(待支付：@item.WaitPay.00)</span>
                                            }
                                        }
                                    </td>
                                    <td style="text-align: center">
                                        <span title="@item.GJFW.Replace(";", "，")">@item.GJFW.Replace(";", "，")</span>
                                    </td>
                                    <td style="text-align: center">
                                        @item.CreateTime.ToString("yyyy-MM-dd")
                                    </td>
                                    <td style="text-align: center">
                                        @if (item.IsDelete)
                                        {
                                            <i>稿件已删除</i>
                                        }
                                        else
                                        {
                                            if (item.Status == ArticleStatus.Open)
                                            {
                                            <a href="/workspace/console/newmanuscriptcheck/@item.Id?journal=@Request.QueryString["journal"]" class="btn btn-primary btn-mini">
                                                初审</a>
                                            }
                                            else if (new List<int>() { 2, 4, 6, 8, 10 }.Contains((int)item.Status))
                                            {
                                                if (item.Status == ArticleStatus.ZhuanShenDaiFenPei)
                                                {
                                            <a href="/workspace/console/distribution/@item.Id?journal=@Request.QueryString["journal"]" 
                                                            class="btn btn-primary btn-mini">专审分配</a>
                                                }
                                                else if (item.Status == ArticleStatus.ZhuanShenWanCheng ||
                                                    item.Status == ArticleStatus.ZhuanShenXiuDingWanCheng)
                                                {
                                                    //4:专审完成,等待确认下一步操作
                                                    //6:专审修订完成
                                            <a href="/workspace/console/CheckAndAcceptance?articleId=@item.Id" class="btn btn-primary btn-mini">
                                                验收</a>
                                                }
                                                else
                                                {
                                                    //8:终审完成
                                                    //10:终审修订完成
                                            <a href="#myZongSFinishBox" onclick="doZhongShenFinish(@item.Id)" data-toggle="modal" class="btn btn-primary btn-mini">
                                                终审验收</a>
                                                }
                                            }
                                            else if (item.Status == ArticleStatus.ZhongShen)
                                            {
                                                //7:终审验收
                                            <a href="#myZongSFinishBox" onclick="doZhongShenFinish(@item.Id)" data-toggle="modal" class="btn btn-primary btn-mini">
                                                终审验收</a>
                                            }
                                            else if (new List<int>() { 1, 20, 80 }.Contains((int)item.Status))
                                            {
                                            <a href="javascript:;" onclick="ConfirmIsPay(@item.Id)" class="btn btn-warning btn-mini">
                                                确认已缴费</a>
                                            }
                                            else if (item.Status == ArticleStatus.ChuBanYiJiaoFei)
                                            {
                                            <a href="#myuploaddinggaoBox" onclick="doDingGao(@item.Id)" data-toggle="modal" class="btn btn-primary btn-mini">
                                                定稿</a>
                                            }
                                            <a href="/workspace/console/articledetail/@item.Id" class="btn btn-success btn-mini">
                                                查看</a>
                                            <a href="javascript:" class="btn btn-danger btn-mini" onclick="cancelarticle(@item.Id)">
                                                删除</a>
                                        }
                                    </td>
                                </tr>
                                    }
                                }
                            }
                        </tbody>
                    </table>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
<div id="myZongSFinishBox" class="modal hide" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">
            ×</button>
        <h3>
            验收结果</h3>
    </div>
    <form id="zsfinishform" class="form-horizontal" action="/workspace/console/conclusiveexamine"
    method="post">
    <input type="hidden" name="articleId" id="hidzsarticleId" />
    <div class="modal-body">
        <div class="widget-content">
            <div class="control-group">
                <label class="control-label" style="width: 80px;">
                    验收结果</label>
                <div class="controls" style="margin-left: 110px;">
                    <select id="sltzsres" name="result" onchange="zschangeexamineresult(this)">
                        <option value="0" selected="selected">录用</option>
                        <option value="1">终审修订</option>
                        <option value="9">终审不通过</option>
                    </select>
                </div>
            </div>
            <div id="feebox" class="control-group">
                <label class="control-label" style="width: 80px;">
                    出版费用</label>
                <div class="controls" style="margin-left: 110px;">
                    <input type="text" id="txttotalpay" name="totalPay" value="@journal.PublicationPrice" />
                </div>
            </div>
            <div id="reszsmsgbox" class="control-group" style="display: none;">
                <label class="control-label" style="width: 80px;">
                    回复消息</label>
                <div class="controls" style="margin-left: 110px;">
                    <textarea id="tarzsmsg" name="msg" rows="6" cols="20"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <input type="submit" class="btn btn-primary" value="确定" />
        <a data-dismiss="modal" class="btn" href="javascript:;">取消</a>
    </div>
    </form>
</div>
<div id="myuploaddinggaoBox" class="modal hide" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">
            ×</button>
        <h3>
            上传定稿</h3>
    </div>
    <form id="dgform" class="form-horizontal" enctype="multipart/form-data" action="/workspace/console/overexamie"
    method="post">
    <input type="hidden" name="articleId" id="hiddgarticleId" />
    <div class="modal-body">
        <div class="widget-content">
            <div class="control-group">
                <label class="control-label" style="width: 80px;">
                    定稿</label>
                <div class="controls" style="margin-left: 110px;">
                    <input type="file" name="Article" />
                    <span class="help-block">支持文件类型：Doc Docx PDF Zip 7-Zip RAR</span>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <input id="btnsumit" type="submit" class="btn btn-primary" value="确定" />
        <a data-dismiss="modal" class="btn" href="javascript:;">取消</a>
    </div>
    </form>
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#likarticle').addClass('open active');
            $('#dgform').submit(function () {
                var file = $('input:file[name="Article"]');
                if (!/\.(doc|docx|pdf|zip|7z|rar)$/i.test(file.val())) {
                    file.parent().parent().addClass('error');
                    file.parent().children('span').remove();
                    file.parent().append(
                            $('<span generated="true" class="help-inline">格式错误.</span>')
                        );
                    return false;
                }
                $('#btnsumit').attr('disabled', 'disabled').val('附件上传中');
            });
            $('#finishform').submit(function () {
                var res = $('#sltres').val();
                var msg = $('#tarmsg').val();
                if (!(res == 0 || res == 2)) {
                    if (msg == '') {
                        $('#tarmsg').parent().parent().addClass('error');
                        $('#tarmsg').parent().children('span').remove();
                        $('#tarmsg').parent().append(
                            $('<span generated="true" class="help-inline">requird.</span>')
                        );
                        return false;
                    }
                }
                var sltval = $('#sltres').val();
                if (confirm('你确认验收此稿件为【' + (sltval == 0 ? "进入终审" : sltval == 1 ? "要求专审修订" : sltval == 2 ? "重新分配专审" : "专审不通过") + '】吗？')) {
                    return true;
                }
                return false;
            });
            $('#zsfinishform').submit(function () {
                var res = $('#sltzsres').val();
                var msg = $('#tarzsmsg').val();
                if (res != 0) {
                    if (msg == '') {
                        $('#tarzsmsg').parent().parent().addClass('error');
                        $('#tarzsmsg').parent().children('span').remove();
                        $('#tarzsmsg').parent().append(
                            $('<span generated="true" class="help-inline">requird.</span>')
                        );
                        return false;
                    }
                }
                else {
                    var fee = $('#txttotalpay').val();
                    if (fee == '' || !/^[0-9\.]+$/.test(fee) || parseFloat(fee, 10) <= 0) {
                        $('#txttotalpay').parent().parent().addClass('error');
                        $('#txttotalpay').parent().children('span').remove();
                        $('#txttotalpay').parent().append(
                            $('<span generated="true" class="help-inline">input error.</span>')
                        );
                        return false;
                    }
                }
                var sltval = $('#sltzsres').val();
                if (confirm('你确认验收此稿件为【' + (sltval == 0 ? "录用" : sltval == 1 ? "终审修订" : "终审不通过") + '】吗？')) {
                    return true;
                }
                return false;
            });
        });
        function cancelarticle(id) {
            if (confirm('确认删除此稿件吗？')) {
                window.location.href = "/workspace/console/CancelArticle/" + id + "?group=@ViewBag.Group";
            }
        }
        function ConfirmIsPay(id) {
            if (confirm('您确认已经收到费用了吗？')) {
                window.location.href = "/workspace/console/ConfirmIsPay/" + id;
            }
        }
        function doZhongShenFinish(id) {
            $('#hidzsarticleId').val(id);
        }
        function zschangeexamineresult(sender) {
            if ($(sender).val() == 0) {
                $('#reszsmsgbox').hide();
                $('#feebox').show();
            }
            else {
                $('#reszsmsgbox').show();
                $('#feebox').hide();
            }
        }
        function doDingGao(id) {
            $('#hiddgarticleId').val(id);
        }
    </script>
}
